/*
 * Copyright 2010 Mark Eschbach.
 *
 * $HeadURL$
 * $Id$
 */
package com.meschbach.cise.resource.jar;

import com.meschbach.cise.iterator.TravelAgent.Visitor;
import com.meschbach.cise.util.StreamCopier;
import java.io.IOException;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import java.util.jar.JarOutputStream;

/**
 *
 * @author "Mark Eschbach" &lt;meschbach@gmail.com&gt;
 */
public class CopyJarEntryVisitor implements Visitor<JarEntry, IOException> {

    JarOutputStream output;
    StreamCopier copier;

    public CopyJarEntryVisitor(JarInputStream jis, JarOutputStream jos) {
        copier = new StreamCopier(jis, jos);
        output = jos;
    }

    public void visitElement(JarEntry anElement) throws IOException {
        output.putNextEntry(anElement);
        copier.doCopy();
    }
}
